﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Chapter03
{
    using Chapter03.View;

    /// <summary>
    /// 第3章 布局
    /// MainWindow.xaml 的交互逻辑
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            #region 01 理解 WPF 中的布局
            /*
             * 01 WPF 布局原则
             * 02 布局过程
             * 03 布局容器
             * */
            #endregion

            #region 02 使用StackPanel 面板进行简单布局
            /*
             * 01 布局属性
             * 02 对齐方式
             * 03 边距
             * 04 最小尺寸、最大尺寸以及显式地设置尺寸
             * 05 Border 控件
             * */
            #endregion

            #region 03 WarpPanel 和 DockPanel 面板
            /*
             * 01 WarpPanel 面板
             * 02 DockPanel 面板
             * 03 嵌套布局容器
             * */
            #endregion

            #region 04 Grid 面板
            /*
             * 01 调整行和列
             * 02 布局舍入
             * 03 跨越行和列
             * 04 分割窗口
             * 05 共享尺寸组
             * 06 UniformGrid 面板
             * */
            #endregion

            #region 05 使用 Canvas 面板进行基于坐标的布局
            /*
             * 01 Z 顺序
             * 02 InkCanvas 元素
             * */
            #endregion

            #region 06 布局示例
            /*
             * 01 列设置
             * 02 动态内容
             * 03 组合式用户界面
             * */
            #endregion

            #region 07 小结
            #endregion
        }

        private void CommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
        {
            if (e.Command == ApplicationCommands.Open)
            {
                var button = e.Source as Button;
                if (button != null)
                {
                    if (button == button1)
                    {
                        var window = new SimpleStackWindow();
                        Demo(window);
                    }
                    if (button == button2)
                    {
                        var window = new WrapPanelsWindow();
                        Demo(window);
                    }
                    if (button == button3)
                    {
                        var window = new SimpleDockWindow();
                        Demo(window);
                    }
                    if (button == button4)
                    {
                        var window = new BasicDialogBoxWindow();
                        Demo(window);
                    }
                    if (button == button5)
                    {
                        var window = new SimpleGridWindow();
                        Demo(window);
                    }
                    if (button == button6)
                    {
                        var window = new SplitWindow();
                        Demo(window);
                    }
                    if (button == button7)
                    {
                        var window = new DoubleSplitWindow();
                        Demo(window);
                    }
                    if (button == button8)
                    {
                        var window = new SharedSizeGroupWindow();
                        Demo(window);
                    }
                    if (button == button9)
                    {
                        var window = new SimpleCanvasWindow();
                        Demo(window);
                    }
                    if (button == button10)
                    {
                        var window = new SimpleInkCanvasWindow();
                        Demo(window);
                    }
                    if (button == button11)
                    {
                        var window = new TextBoxColumnWindow();
                        Demo(window);
                    }
                    if (button == button12)
                    {
                        var window = new DynamicContentWindow();
                        Demo(window);
                    }
                    if (button == button13)
                    {
                        var window = new ModularContentWindow();
                        Demo(window);
                    }
                }
            }
        }

        private void Demo(Window window)
        {
            window.Owner = this;
            window.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            window.ShowDialog();
        }
    }
}
